
-- =============================================    



-- Author:  <Author,,Name>    



-- Create date: <Create Date,,>    



-- Description: <Description,,>    



-- =============================================    



ALTER PROCEDURE [dbo].[GetTodayMatche]  -- 1



 -- Add the parameters for the stored procedure here    



 @MatchType INT



     



AS    



BEGIN    



 -- SET NOCOUNT ON added to prevent extra result sets from    



 -- interfering with SELECT statements.    



 SET NOCOUNT ON;    



    



    -- Insert statements for procedure here    



   

 SELECT ms.Id as Id, t.TeamName as Team1 ,t1.TeamName as Team2, (t.TeamName + ' VS ' + t1.TeamName) as Teams,Date, Time,  

 t.Id as TeamAId, t1.Id as TeamBId   

 from MatchSchedule ms    

 INNER JOIN Team t on ms.Team1 = t.Id    

 INNER JOIN Team t1 on ms.Team2 = t1.Id   

 WHERE CAST(ms.Date as DATE) <= CAST(GETUTCDATE() as DATE) and 

 ms.IsActive = 1 and ms.IsDeleted = 0   

 and ms.MatchType = @MatchType and ms.Id NOT IN (Select MatchScheduleId from Result )



     



END
